<!DOCTYPE html>
<html>

<head>
    <title>加入校友企业库 - {$site_info.site_name|default=''}</title>
    <meta name="keywords" content="{$site_info.site_seo_keywords|default=''}" />
    <meta name="description" content="{$site_info.site_seo_description|default=''}">
    <include file="public@head" />
    <link href="__STATIC__/js/tag-editor/jquery.tag-editor.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
    </style>
    <script type="text/html" id="photos-item-tpl">
        <li id="saved-image{id}">
            <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
            <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}" style="width: 200px;" title="图片名称">
            <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="imagePreviewDialog(this.src);">
            <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
            <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
        </li>
    </script>
</head>

<body class="bg-light">
    <include file="public@nav" />
    <section class="bg-light py-4">
        <div class="container">
            <div class="text-center text-dark">
                <h5 class="">校友企业入驻</h5>
                <p class="mb-0">
                    本社区为非官方社区，欢迎大家自由选择发言。
                    <br>建立校友名片录，旨在帮助校友间合作与交流。
                    <br>
                    <br>
                    <span class="badge badge-pill badge-info"><i class="fa fa-id-card-o"></i> 校友企业入驻</span>
                </p>
            </div>
        </div>
    </section>
    <section class="container">
        <div class="row">
            <div class="col-2">
                <div class="card border-0 mb-3">
                    <div class="card-body">
                        <div class="text-center">
                            关注微信公众号
                            <br><span class="badge badge-info">新梅陇客栈</span>
                            <img src="/assets/dist/images/qrcode.jpg" class="img-fluid">
                        </div>
                    </div>
                </div>
                <div class="card border-0 mb-3">
                    <div class="card-body">
                        <h6>关于社区</h6>
                        <ul class="list-unstyled">
                            <li><a href="{:cmf_url('portal/Page/index',array('id'=>40))}">联系我们</a></li>
                            <li><a href="{:cmf_url('portal/Page/index',array('id'=>39))}">关于我们</a></li>
                            <li><a href="{:cmf_url('portal/Page/index',array('id'=>39))}">近期活动</a></li>
                        </ul>
                        <h6>快捷联系</h6>
                        <ul class="list-unstyled m-0">
                            <li><a href="tel:(+86) 159-2158-7537"><i class="fa fa-phone"></i> 159-2158-7537</a></li>
                            <li><a href="mailto:supu@vip.qq.com"><i class="fa  fa-envelope-o"></i> supu@vip.qq.com</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="col-7">
                <div class="card border-0">
                    <div class="card-body">
                        <h6>校友企业入驻</h6>
                        <form action="{:url('schain/Enterprise/addPost')}" method="post" class="form-horizontal js-ajax-form form-enterprise">
                            <div class="form-row">
                                <div class="form-group col-6">
                                    <label for="js-categories-name-input">所属行业 <span class="form-required">*</span></label>
                                    <input class="form-control" type="text" required value="" placeholder="请选择分类" onclick="doSelectCategory();" id="js-categories-name-input" readonly/>
                                    <input class="form-control" type="hidden" value="" name="post[categories]" id="js-categories-id-input" />
                                </div>
                                <div class="form-group col-6">
                                    <label for="name">企业名称</label>
                                    <input class="form-control" type="text" name="post[ent_title]" id="title" required value="" placeholder="请输入企业名称" />
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="form-group col-6">
                                    <label for="js-categories-name-input">企业地址 <span class="form-required">*</span></label>
                                    <input class="form-control" type="text" name="post[ent_address]" id="title" required value="" placeholder="请输入企业名称" />
                                </div>
                                <div class="form-group col-6">
                                    <label for="js-categories-name-input">企业联系人<span class="form-required">*</span></label>
                                    <input type="text" required class="form-control" name="post[ent_contacts]" placeholder="请输入您的企业联系人">
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="form-group col-6">
                                    <label for="js-categories-name-input">企业电话 <span class="form-required">*</span></label>
                                    <input class="form-control" type="text" name="post[ent_tell]" id="title" required value="" placeholder="请输入企业名称" />
                                </div>
                                <div class="form-group col-6">
                                    <label for="js-categories-name-input">企业邮箱<span class="form-required">*</span></label>
                                    <input type="text" class="form-control" name="post[ent_email]" placeholder="请输入您的企业邮箱">
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="form-group col-6">
                                    <label for="js-categories-name-input">企业网址 <span class="form-required">*</span></label>
                                    <input class="form-control" type="text" name="post[ent_website]" id="title" required value="" placeholder="请输入企业名称" />
                                </div>
                                <div class="form-group col-6">
                                    <label for="ent_keywords">标签 · <small>多个标签用逗号","分隔开</small></label>
                                    <input class="form-control" type="text" name="post[ent_keywords]" id="ent_keywords" value="" placeholder="如'化工,生活用品'" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="js-categories-name-input">详细介绍</label>
                                <script type="text/plain" required id="content" name="post[ent_content]"></script>
                            </div>
                            <div class="form-group">
                                <label for="logo">企业LOGO</label>
                                <div>
                                    <input type="hidden" name="post[more][thumbnail]" id="thumbnail" value="">
                                    <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                                <img src="/assets/dist/images/default-thumbnail.png"
                                                     id="thumbnail-preview"
                                                     width="135" style="cursor: pointer"/>
                                            </a>
                                    <input type="button" class="btn btn-primary btn-sm btn-cancel-thumbnail" value="取消图片">
                                </div>
                            </div>
                            <hr>
                            <div class="form-group mb-0">
                                <button type="submit" class="btn btn-primary js-ajax-submit mr-4">{:lang('ADD')}</button>
                                <button type="button" class="btn btn-light" onclick="javascript:history.go(-1);">{:lang('BACK')}</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-3">
                <div class="sticky-top">
                    <div class="card border-0 user-card">
                        <img class="card-img-top" src="/assets/dist/images/card_bg.jpg" alt="Card image cap">
                        <div class="card-body">
                            <div class="text-center">
                                <div style="margin-top:-60px" class="mx-auto">
                                    <empty name="$user.avatar">
                                        <a href="{:url('user/profile/avatar')}">
                                            <img src="/assets/dist/images/headicon_128.png" class="headicon rounded-circle shadow-sm" alt="{$user.user_nickname}">
                                        </a>
                                        <else/>
                                        <a href="{:url('user/profile/center')}">
                                            <img src="{:cmf_get_user_avatar_url($user.avatar)}" class="headicon rounded-circle shadow-sm" alt="{$user.user_nickname}">
                                        </a>
                                    </empty>
                                </div>
                                <h6 class="my-2">{$user.user_nickname}</h6>
                                <p class="card-text">{$user.signature|default="这家伙有点懒，什么都没留下"}</p>
                                <if condition="$user eq false">
                                    <a class="btn btn-info btn-sm" href="{:cmf_url('user/Login/index')}">立即登录</a>
                                </if>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <include file="public@footer" />
    <include file="public@scripts" />
    <script type="text/javascript" src="__STATIC__/js/frontend.js"></script>
    <script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
    </script>
    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
    <!-- tag-editor -->
    <script src="https://code.jquery.com/ui/1.10.2/jquery-ui.min.js"></script>
    <script type="text/javascript" src="__STATIC__/js/tag-editor/jquery.caret.min.js"></script>
    <script type="text/javascript" src="__STATIC__/js/tag-editor/jquery.tag-editor.js"></script>
    <script type="text/javascript">
    $(function() {
        editorcontent = new baidu.editor.ui.Editor({
            toolbars: [
                ['bold', 'removeformat', 'link', 'insertimage', 'insertvideo', 'indent', 'justifyleft', 'justifycenter', 'fontsize', 'fullscreen']
            ],
            initialFrameHeight: 400,
            retainOnlyLabelPasted: true,
        });
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {}

        $('.btn-cancel-thumbnail').click(function() {
            $('#thumbnail-preview').attr('src', '/assets/dist/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });
    </script>
    <script type="text/javascript">
    $(function() {
        // 标签输入组
        var ArticleTag = $('#article-tag');
        var TagListContent = $('.tag-list-content');
        var TagList = $(TagListContent).children();
        var maxTagNum = 5,
            onChangeTagNum = 0,
            beforeRemoveTagNum = 0,
            beforeSaveTagNum = 0;
        var tagStr = '';
        ArticleTag.tagEditor({
            maxTags: maxTagNum,
            placeholder: '请填写您企业的标签',
            autocomplete: {
                delay: 0, // show suggestions immediately
                position: { collision: 'flip' }, // automatic menu position up/down
                source: ['自然', '生态体验']
            },
            onChange: function(field, editor, tags) {
                onChangeTagNum = tags.length;
                tagStr = tags;
                $('#ent_keywords').val(tagStr.toString());
            },
            beforeTagSave: function(field, editor, tags, tag, val) {
                beforeSaveTagNum = tags.length;
                $.each(TagList, function(index, obj) {
                    if ($(obj).text() == val) {
                        $(obj).addClass('on');
                    }
                });
            },
            beforeTagDelete: function(field, editor, tags, val) {
                afterRemoveTagNum = tags.length;
                $.each(TagList, function(index, obj) {
                    if ($(obj).text() == val) {
                        $(obj).removeClass('on');
                    }
                });

                if (onChangeTagNum <= maxTagNum) {
                    $('#tag-tips').hide('fast');
                }
            }
        });

        //点击标签输入框显示常用标签组
        $('.tag-editor').click(function(event) {
            $('.tag-list').show('fast');
        });
        $(document).on('click', function(e) {
            $('#tag-list').hide('fast');
        });
        $('#tag-list').on('click', function(e) {
            e.stopPropagation();
        });


        //选择常用标签
        $('.tag-list-tag').click(function(event) {
            var tag = $(this).text();
            //当前tag数量小于限制数时可点击
            currentTagNum = onChangeTagNum;

            if (currentTagNum == maxTagNum) {
                $('#tag-tips span').text('最多增加' + maxTagNum + '个标签');
                $('#tag-tips').show('fast');
                if ($(this).hasClass('on')) {
                    ArticleTag.tagEditor('removeTag', tag);
                    $(this).removeClass('on');
                }
            } else if (currentTagNum < maxTagNum) {
                if (!$(this).hasClass('on')) {
                    $(this).addClass('on');
                    ArticleTag.tagEditor('addTag', tag);
                } else {
                    ArticleTag.tagEditor('removeTag', tag);
                    $(this).removeClass('on');
                }
                $('#tag-tips').hide('fast');
            } else if (currentTagNum > maxTagNum) {
                $('#tag-tips').hide('fast');
            }

        });
    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('businesscard/Card/select')}?ids=" + selectedCategoriesId, '请选择分类', {
            area: ['400px', '400px'],
            btn: ['确定', '取消'],
            yes: function(index, layero) {
                //do something

                var iframeWin = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
    </script>
</body>

</html>